package com.xja.service.impl;

/*import org.springframework.stereotype.Service;
import javax.annotation.Resource;*/
import com.xja.entity.CoursePerson;
import com.xja.mapper.CoursePersonMapper;
import com.xja.service.CoursePersonService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class CoursePersonServiceImpl implements CoursePersonService{

    @Autowired
    private CoursePersonMapper coursePersonMapper;

    @Override
    public int deleteByPrimaryKey(Integer cpid) {
        return coursePersonMapper.deleteByPrimaryKey(cpid);
    }

    @Override
    public int insert(CoursePerson record) {
        return coursePersonMapper.insert(record);
    }

    @Override
    public int insertSelective(CoursePerson record) {
        return coursePersonMapper.insertSelective(record);
    }

    @Override
    public CoursePerson selectByPrimaryKey(Integer cpid) {
        return coursePersonMapper.selectByPrimaryKey(cpid);
    }

    @Override
    public int updateByPrimaryKeySelective(CoursePerson record) {
        return coursePersonMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(CoursePerson record) {
        return coursePersonMapper.updateByPrimaryKey(record);
    }

    @Override
    public CoursePerson selectCourseByUid(Integer uid,Integer cid) {
        return coursePersonMapper.selectCourseByUid(uid,cid);
    }

    @Override
    public boolean addPerson(Integer cid, Integer uid) {
        //添加用户关联
        int row = coursePersonMapper.addPerson(cid,uid);
        //课程报名人数增加
        int row1 = coursePersonMapper.updateNumber(cid);
        if(row>0){
            return true;
        }
        return false;
    }

}
